/**
 * 
 */
package netPortfolioValue;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author mingfan
 * This class defines a record of stock price quotation retrieved from Yahoo Finance API
 * Its structure is
 * 		Date
 * 		Open Price
 * 		High price
 * 		Low Price
 * 		Close Price
 * 		Volume
 * 		Adjust Close Price
 * For Yahoo Financial API, one line of price quotation looks like:
 *	2011-03-17,336.83,339.61,330.66,334.64,23519400,334.64
 */
public class YahooPriceRecord {

	private final double openPrice;
	private final double highPrice;
	private final double lowPrice;
	private final double closePrice;
	private final double adjustClosePrice;
	private 	  Date date;
	private final long volume;
	
	/**
	 * @param strOpenPrice
	 * @param strHighPrice
	 * @param strLowPrice
	 * @param strClosePrice
	 * @param strAdjustClosePrice
	 * @param strDate
	 * @param strVolume
	 */
	public YahooPriceRecord(final String strDate, 
							final String strOpenPrice, 
							final String strHighPrice,
							final String strLowPrice, 
							final String strClosePrice, 
							final String strVolume,
							final String strAdjustClosePrice) {
		super();
		
		this.openPrice = Double.parseDouble(strOpenPrice);
		this.highPrice = Double.parseDouble(strHighPrice);
		this.lowPrice = Double.parseDouble(strLowPrice);
		this.closePrice = Double.parseDouble(strClosePrice);
		this.adjustClosePrice = Double.parseDouble(strAdjustClosePrice);
		
		try {
			this.date = (new SimpleDateFormat("yyyy-MM-dd")).parse(strDate);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			System.out.println("Unparseable date: " + strDate);
			e.printStackTrace();
		}
		
		this.volume = Long.parseLong(strVolume);
	}

	/**
	 * @return the openPrice
	 */
	public double getOpenPrice() {
		return openPrice;
	}

	/**
	 * @return the highPrice
	 */
	public double getHighPrice() {
		return highPrice;
	}

	/**
	 * @return the lowPrice
	 */
	public double getLowPrice() {
		return lowPrice;
	}

	/**
	 * @return the closePrice
	 */
	public double getClosePrice() {
		return closePrice;
	}

	/**
	 * @return the adjustClosePrice
	 */
	public double getAdjustClosePrice() {
		return adjustClosePrice;
	}

	/**
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * @return the volume
	 */
	public long getVolume() {
		return volume;
	}
	
}
